/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commands;

import java.util.Vector;
import javax.swing.DefaultListModel;
import entityclasses.Person;

/**
 *
 * @author YCAN
 */
public class SearchOnlyLastNameCommand implements ISearchCommand{

    public DefaultListModel execute(DefaultListModel results,Vector <Person> v,String text) {
        
        String meaningfullText[] = text.split(" ");
        if(v.size() > 0)
        for(Person p : v)
        {
            if(p.getLastName().toLowerCase().contains(meaningfullText[meaningfullText.length-1].toLowerCase()))
            {
                results.addElement(p);
            }
        }
        
        return results;
    }
    
}
